package com.storm.demo;

import org.apache.storm.topology.BasicOutputCollector;
import org.apache.storm.topology.OutputFieldsDeclarer;
import org.apache.storm.topology.base.BaseBasicBolt;
import org.apache.storm.tuple.Fields;
import org.apache.storm.tuple.Tuple;
import org.apache.storm.tuple.Values;

/**
 * =================================
 * <p>
 * Created by cjj on 2018/10/23.
 * <p>
 * 描述: 大写逻辑
 */

public class UpperBlot extends BaseBasicBolt {

    //业务处理逻辑
    @Override
    public void execute(Tuple tuple, BasicOutputCollector collector) {
        //先获取上一个数组传递过来的数据，数据在tuple里面
        String string = tuple.getString(0);

        //逻辑，将单词大写
        String s = string.toUpperCase();

        collector.emit(new Values(s));
    }

    //输出
    @Override
    public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {
        outputFieldsDeclarer.declare(new Fields("upperName"));
    }
}
